<%--
  Created by IntelliJ IDEA.
  User: TLY
  Date: 2022/12/8
  Time: 11:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="./common/taglibs.jsp" %>
${jquery_js}
${validate_jquery_js}
${form_jquery_js}

<html>
<head>
    <title>理发店业务管理系统</title>
    <link type="text/css" rel="stylesheet" href="${ctx}/css/style.css"/>
    <script type="text/javascript" src="${ctx}/scripts/index.js"></script>
    <style>
        label{
            color:red
        }
    </style>
</head>
<body>
<div id="header" class="wrap">

    <div class="navbar">
        <ul class="clearfix">
            <li><a href="${ctx}/index.jsp">首页</a></li>
            <li class="current"><a href="${ctx}/user/getpageusers">会员管理</a></li>
            <li><a href="${ctx}/staff/getstaffs">职工管理</a></li>
            <li><a href="${ctx}/order/getorders">订单管理</a></li>
        </ul>
    </div>
</div>
<div id="childNav">
    <div class="welcome wrap">
        管理员${admin.name}您好，欢迎回到管理后台。
    </div>
</div>

<div id="main" class="wrap">
    <div id="menu-mng" class="lefter">
        <div class="box">
            <dl>
                <dt><a href="${ctx}/user/getpageusers">会员管理</a></dt>
                <dd><em></em><a href="${ctx}/user/adduser">新增会员</a></dd>
                <dd><em></em><a href="${ctx}/user/topUp">会员充值</a></dd>
        <%--        <dt>职工管理</dt>
                <dd><em></em><a href="${ctx}/pageproductclass">新增职工</a></dd>
                <dt>订单管理</dt>
                <dd><em></em><a href="${ctx}/pageproductclass">新增职工</a></dd>--%>
            </dl>
        </div>
    </div>
    <div class="main">
        <h2>修改会员信息</h2>
        <div class="manage">
            <form action="#" id="myform">
                <table class="form">

                    <tr hidden>
                        <td><input type="text" class="text" name="userid" value="${updateuser.userid}" required/></td>
                    </tr>


                    <tr>
                        <td class="field">用户名(*)：</td>
                        <td><input type="text" class="text" name="username" value="${updateuser.username}" required maxlength="10"/></td>
                    </tr>

                    <tr>
                        <td class="field">登录密码(*)：</td>
                        <td><input type="text" class="text" name="userpwd" value="${updateuser.userpwd}" required/></td>
                    </tr>
                    <tr>
                        <td class="field">性别(*)：</td>
                        <td>

                            <input type="radio" name="sex" value="1" <c:if test="${updateuser.sex==1}">checked="checked" </c:if>/>男
                            <input type="radio" name="sex" value="0"<c:if test="${updateuser.sex==0}">checked="checked" </c:if>/>女
                        </td>
                    </tr>
                    <tr>
                        <td class="field">余额(*)：</td>
                        <td><input type="text" class="text" name="money" value="${updateuser.money}" maxlength="10"/></td>
                    </tr>

                    <tr>
                    <td class="field">描述(*)：</td>

                    <td><input type="text" class="text" name="describe" value="${updateuser.describe}" maxlength="20"/></td>

                    </tr>

                    <tr>
                        <td class="field">手机(*)：</td>
                        <td><input type="text" class="text" name="phone" value="${updateuser.phone}"/></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td><label class="ui-blue"><input type="button" name="button" id="btn" value="修改"/></label></td>
                    </tr>

                </table>
            </form>
        </div>
    </div>
    <div class="clear">

    </div>
</div>

<div id="footer">
    安徽大学江淮学院 2019级 计算机科学与技术专业 陶龙宇 学号JB194033
</div>
<script type="text/javascript">
    $(function () {

        $("#btn").click(function () {
            if($("#myform").valid()){
            var params = $("#myform").serialize();//获取表单参数值
            $.ajax({
                url: "${ctx}/user/userupdate",
                type: "post",
                data: params,
                dataType: "json",
                success: function (result) {
                    alert(result.msg)
                    if (result.code == 10000) {
                        location.href = "${ctx}/user/getpageusers";
                    }
                },
                error: function () {
                    alert("请联系管理员")
                },
            })

        }
        })


        $("#myform").validate({
            rules:{
                "username":{
                    required:true
                },
                "userpwd":{
                    required:true,
                    rangelength:[5,16]

                },
                "sex":{
                    required:true
                },
                "money":{
                    required:true,
                    min:0,
                    number:true
                },
                "phone":{
                    required:true,
                    phonelimit:true

                }
            },
            messages:{
                "username":{
                    required:"*请输入会员姓名"
                },
                "userpwd":{
                    required:"*请输入密码",
                    rangelength:"*密码长度在5-16位"
                },
                "sex":{
                    required:"*请输入性别"
                },
                "money":{
                    required:"*余额不能为空",
                    min:"*最小为0",
                    number:"*请输入正确的数字"
                },
                "phone":{
                    required:"*手机号不能为空"
                }

            }

        })

        $.validator.addMethod("phonelimit",function(value,element){
            var rule = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
            return this.optional(element)||(rule.test(value))
        },"*请输入正确的手机号")


    })


</script>

</body>
</html>
